/*----------------------------------------------------------------
 * \file        ct_voip_msg_cache_mgr.h
 * \author      lilian lilian@hujiang.com
 * \date        2014/08/08
 * \brief
 *      the manager of VOIP packet cache, used for Lost Packet Resend.
 *----------------------------------------------------------------*/
#ifndef CTVOIP_MSG_CACHE_MGR_H_
#define CTVOIP_MSG_CACHE_MGR_H_

#include "command.h"
#include <map>

class ctVOIPMsgCache;
class ctVOIPMsg;

class ctVOIPMsgCacheMgr {
        public:
                ctVOIPMsgCacheMgr(int cachecount=30);
                ~ctVOIPMsgCacheMgr();

        public:
                void		addMsg(uint32_t uid, uint32_t seq, ctVOIPMsg* msg);
                ctVOIPMsg*	getMsg(uint32_t uid, uint32_t seq);
                void	        clearCache(uint32_t uid);
                void            checkTimeout();

        private:
                //<userid, ctVOIPMsgCache>
                typedef std::map<uint32_t, ctVOIPMsgCache*> CacheMap;
        private:
                int             cache_count_;
                CacheMap        cache_map_;
};

#endif //CTVOIP_MSG_CACHE_MGR_H_
